#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int a, b, c;
int check(int i, int j, int k)
{
	i= i % 100;
	if (a == i && b == j && c == k)
	{
		return 1;
	}
	if (a == j && b == k && c == i)
	{
		return 1;
	}
	if (a == k && b == j && c == i)
	{
		return 1;
	}
	else
		return 0;
}
int main()
{
	scanf("%d/%d/%d", &a, &b, &c);
	int month[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
	for (int i = 1960; i <=2059; i++)
	{
		if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0)
		{
			month[2] = 29;
		}
		else
		{
			month[2] = 28;
		}

		for (int j = 1; j <= 12; j++)
		{
			for (int k = 1; k <= month[j]; k++)
			{
				if (check(i, j, k))
				{
					printf("%d-%02d-%02d\n", i, j, k);
				}
			}
		}
	}
	return 0;
}